package com.example.demo.arithmetic.algorithm.recursion;

/**
 * @Description: 递归实现阶乘
 * @Author: LLL
 * @Date: 2020-03-14 22:05
 **/
public class ResFactorial {

    public static void main(String[] args) {
        int i = factorial(4);
        System.out.println(i);
    }

    /*
     *
     * Description:阶乘
     *
     * @param i
     * @return: int
     * @author: liull
     * @date: 2020/3/14 22:20
     */
    public static int factorial(int i) {
        if (i == 0) {
            return 1;
        } else {
            return i * factorial(i - 1);
        }
    }
}
